// Copyright [2020] <unknown>
#include <bits/stdc++.h>
using namespace std;
// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#define dbg(x...) { cerr << "\033[32;1m" << #x << " -> "; err(x); }
void err() { cerr << "\033[39;0m" << endl; }
template<typename T, typename... A>
void err(T a, A... x) { cerr << a << ' '; err(x...); }
#else
#define dbg(...)
#endif

#define sz(x) ((int)x.size())

typedef long long LL;

const int N = 15, M = 1050;

char s[N][M];

int n, m, k;

inline int lowbit(int x) { return x & (-x); }
int mp[1<<(N+2)];

int sum[N][M];

int main(int argc, char const *argv[]) {
    // code
    for (int i=0; i<N; ++i)
        mp[1<<i] = i;

    scanf("%d%d%d", &n, &m, &k);
    for (int i=1; i<=n; ++i) {
        scanf("%s", s[i]);
        for (int j=0; j<m; ++j)
            sum[i][j] =( s[i][j] == '1') + sum[i-1][j];
    }


    int lim = 1 << (n-1);
    int ans = n * m;
    for (int mask=0; mask<lim; ++mask) {
        vector<int> row;
        row.push_back(0);
        for (int i=mask; i; i-=lowbit(i)) {
            row.push_back(mp[lowbit(i)] + 1);
        }
        row.push_back(n);

        vector<vector<int>> dat;
        int nn = row.size()-1, mm = m;
        dat.resize(nn+1);
        for (int i=1; i<=nn; ++i) {
            dat[i].resize(m);
            for (int j=0; j<m; ++j)
                dat[i][j] = sum[row[i]][j] - sum[row[i-1]][j];
        }
        bool suc = true;
        for (int i=1; i<=nn; ++i) {
            for (int j=0; j<m; ++j) {
                if (dat[i][j] > k) {
                    suc = false;
                    break;
                }
            }
            if (!suc)
                break;
        }
        if (!suc) continue;
        // dbg(mask, nn);
        // for (int i=1; i<=nn; ++i)
        //     for (int j=0; j<m; ++j)
        //         printf("%d%c", dat[i][j], j==m-1? '\n' : ' ');
        // return 0;
        
        int tans = nn-1;
        static int cnt[N];
        memset(cnt, 0, sizeof cnt);
        for (int j=0; j<m; ++j) {
            bool flag = false;
            for (int i=1; i<=nn; ++i) {
                if (cnt[i] + dat[i][j] > k) {
                    flag = true;
                    break;
                }
            }
            if (flag) {
                ++tans;
                memset(cnt, 0, sizeof cnt);
            }
            for (int i=1; i<=nn; ++i)
                cnt[i] += dat[i][j];
        }
        ans = min(ans, tans);

    }
    printf("%d\n", ans);

    return 0;
}
